void swap(int* a, int* b){
		int tmp = *a;
		*a = *b;
		*b = tmp;
	}

	//partition array according to array[i]
	int partition(int* array, int left, int right, int pivotIndex){
		int pivotValue,storeIndex,i;
		pivotValue = array[pivotIndex];
		swap(&array[pivotIndex], &array[right]);
		storeIndex = left;
		for (i = left;i < right; i++){
			if (array[i] < pivotValue){
				swap(&array[storeIndex], &array[i]);
				storeIndex ++;
			}
		}
		swap(&array[right], &array[storeIndex]);
		return storeIndex;
	}
	
	void qsort(int* array, int left, int right){
		int pivotNewIndex;
		if(right > left){
			pivotNewIndex = partition(array, left, right, left);
			qsort(array, left, pivotNewIndex-1);
			qsort(array, pivotNewIndex+1, right);
		}
	}
	
	void sort(int* array, int len){
		qsort(array, 0, len-1);
	}
	
	int ordered(int* array, int len){
		int i;
		for(i=1;i<len;i++){
			if(array[i-1]>array[i]){
				return 0;
			}
		}
		return -1;
	}

	
	
int main(){
	int arr[] = {5, 4, 2, 7, 0, 6, 1, 3, 8, 9};
	if(ordered(arr,10)){
		return 1;
	}
	sort(arr,10);
	if(!ordered(arr,10)){
		return 1;
	}
	return 0;
}